#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#define two(x) (x)*(x)
using namespace std;
int main() {
	int n,m,x,y;
	while(scanf("%d%d",&n,&m)!=EOF) {
		if(n==0&&m==0) printf("%d\n",1);
		m*=-1;
		int dim = max(abs(n),abs(m));
		dim=2*dim-1;
		for(int i=two(dim);i<two(dim+2);i++) {
			int p = i-two(dim);
			if(p/(dim+1)==0) {
				x=(dim+1)/2;
				y=(dim+1)/2-1-p%(dim+1);
			} else if(p/(dim+1)==1) {
				x=(dim+1)/2-1-p%(dim+1);
				y=-1*(dim+1)/2;
			} else if(p/(dim+1)==2) {
				x=-1*(dim+1)/2;
				y=p%(dim+1)+1-(dim+1)/2;
			} else {
				x=p%(dim+1)+1-(dim+1)/2;
				y=(dim+1)/2;
			}
			if(x==n&&y==m) {
				printf("%d\n",i+1);
				break;
			}
		}		
	}
	return 0;
}
